<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - code analysis - src/caffe/util/math_functions.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">src/caffe/util</a> - math_functions.cpp<span style="font-size: 80%;"> (source / <a href="math_functions.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">code analysis</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">46</td>
            <td class="headerCovTableEntry">144</td>
            <td class="headerCovTableEntryLo">31.9 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2020-09-11 22:50:33</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">17</td>
            <td class="headerCovTableEntry">60</td>
            <td class="headerCovTableEntryLo">28.3 %</td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #include &lt;boost/math/special_functions/next.hpp&gt;</a>
<span class="lineNum">       2 </span>            : #include &lt;boost/random.hpp&gt;
<span class="lineNum">       3 </span>            : 
<span class="lineNum">       4 </span>            : #include &lt;limits&gt;
<span class="lineNum">       5 </span>            : 
<span class="lineNum">       6 </span>            : #include &quot;caffe/common.hpp&quot;
<span class="lineNum">       7 </span>            : #include &quot;caffe/util/math_functions.hpp&quot;
<span class="lineNum">       8 </span>            : #include &quot;caffe/util/rng.hpp&quot;
<span class="lineNum">       9 </span>            : 
<span class="lineNum">      10 </span>            : namespace caffe {
<a name="11"><span class="lineNum">      11 </span>            : </a>
<span class="lineNum">      12 </span>            : template&lt;&gt;
<span class="lineNum">      13 </span><span class="lineCov">    6258724 : void caffe_cpu_gemm&lt;float&gt;(const CBLAS_TRANSPOSE TransA,</span>
<span class="lineNum">      14 </span>            :     const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
<span class="lineNum">      15 </span>            :     const float alpha, const float* A, const float* B, const float beta,
<span class="lineNum">      16 </span>            :     float* C) {
<span class="lineNum">      17 </span><span class="lineCov">    6258724 :   int lda = (TransA == CblasNoTrans) ? K : M;</span>
<span class="lineNum">      18 </span><span class="lineCov">    6258724 :   int ldb = (TransB == CblasNoTrans) ? N : K;</span>
<span class="lineNum">      19 </span>            :   cblas_sgemm(CblasRowMajor, TransA, TransB, M, N, K, alpha, A, lda, B,
<span class="lineNum">      20 </span><span class="lineCov">    6258724 :       ldb, beta, C, N);</span>
<span class="lineNum">      21 </span><span class="lineCov">    6258724 : }</span>
<a name="22"><span class="lineNum">      22 </span>            : </a>
<span class="lineNum">      23 </span>            : template&lt;&gt;
<span class="lineNum">      24 </span><span class="lineNoCov">          0 : void caffe_cpu_gemm&lt;double&gt;(const CBLAS_TRANSPOSE TransA,</span>
<span class="lineNum">      25 </span>            :     const CBLAS_TRANSPOSE TransB, const int M, const int N, const int K,
<span class="lineNum">      26 </span>            :     const double alpha, const double* A, const double* B, const double beta,
<span class="lineNum">      27 </span>            :     double* C) {
<span class="lineNum">      28 </span><span class="lineNoCov">          0 :   int lda = (TransA == CblasNoTrans) ? K : M;</span>
<span class="lineNum">      29 </span><span class="lineNoCov">          0 :   int ldb = (TransB == CblasNoTrans) ? N : K;</span>
<span class="lineNum">      30 </span>            :   cblas_dgemm(CblasRowMajor, TransA, TransB, M, N, K, alpha, A, lda, B,
<span class="lineNum">      31 </span><span class="lineNoCov">          0 :       ldb, beta, C, N);</span>
<span class="lineNum">      32 </span><span class="lineNoCov">          0 : }</span>
<a name="33"><span class="lineNum">      33 </span>            : </a>
<span class="lineNum">      34 </span>            : template &lt;&gt;
<span class="lineNum">      35 </span><span class="lineCov">    2150064 : void caffe_cpu_gemv&lt;float&gt;(const CBLAS_TRANSPOSE TransA, const int M,</span>
<span class="lineNum">      36 </span>            :     const int N, const float alpha, const float* A, const float* x,
<span class="lineNum">      37 </span>            :     const float beta, float* y) {
<span class="lineNum">      38 </span><span class="lineCov">    2150064 :   cblas_sgemv(CblasRowMajor, TransA, M, N, alpha, A, N, x, 1, beta, y, 1);</span>
<span class="lineNum">      39 </span><span class="lineCov">    2150064 : }</span>
<a name="40"><span class="lineNum">      40 </span>            : </a>
<span class="lineNum">      41 </span>            : template &lt;&gt;
<span class="lineNum">      42 </span><span class="lineNoCov">          0 : void caffe_cpu_gemv&lt;double&gt;(const CBLAS_TRANSPOSE TransA, const int M,</span>
<span class="lineNum">      43 </span>            :     const int N, const double alpha, const double* A, const double* x,
<span class="lineNum">      44 </span>            :     const double beta, double* y) {
<span class="lineNum">      45 </span><span class="lineNoCov">          0 :   cblas_dgemv(CblasRowMajor, TransA, M, N, alpha, A, N, x, 1, beta, y, 1);</span>
<span class="lineNum">      46 </span><span class="lineNoCov">          0 : }</span>
<a name="47"><span class="lineNum">      47 </span>            : </a>
<span class="lineNum">      48 </span>            : template &lt;&gt;
<span class="lineNum">      49 </span><span class="lineCov">     160000 : void caffe_axpy&lt;float&gt;(const int N, const float alpha, const float* X,</span>
<span class="lineNum">      50 </span><span class="lineCov">     160000 :     float* Y) { cblas_saxpy(N, alpha, X, 1, Y, 1); }</span>
<a name="51"><span class="lineNum">      51 </span>            : </a>
<span class="lineNum">      52 </span>            : template &lt;&gt;
<span class="lineNum">      53 </span><span class="lineNoCov">          0 : void caffe_axpy&lt;double&gt;(const int N, const double alpha, const double* X,</span>
<span class="lineNum">      54 </span><span class="lineNoCov">          0 :     double* Y) { cblas_daxpy(N, alpha, X, 1, Y, 1); }</span>
<a name="55"><span class="lineNum">      55 </span>            : </a>
<span class="lineNum">      56 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      57 </span><span class="lineCov">     861026 : void caffe_set(const int N, const Dtype alpha, Dtype* Y) {</span>
<span class="lineNum">      58 </span><span class="lineCov">     861026 :   if (alpha == 0) {</span>
<span class="lineNum">      59 </span><span class="lineCov">     740000 :     memset(Y, 0, sizeof(Dtype) * N);  // NOLINT(caffe/alt_fn)</span>
<span class="lineNum">      60 </span>            :     return;
<span class="lineNum">      61 </span>            :   }
<span class="lineNum">      62 </span><span class="lineCov">12532443262 :   for (int i = 0; i &lt; N; ++i) {</span>
<span class="lineNum">      63 </span><span class="lineCov"> 6266161118 :     Y[i] = alpha;</span>
<span class="lineNum">      64 </span>            :   }
<span class="lineNum">      65 </span>            : }
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            : template void caffe_set&lt;int&gt;(const int N, const int alpha, int* Y);
<span class="lineNum">      68 </span>            : template void caffe_set&lt;float&gt;(const int N, const float alpha, float* Y);
<span class="lineNum">      69 </span>            : template void caffe_set&lt;double&gt;(const int N, const double alpha, double* Y);
<a name="70"><span class="lineNum">      70 </span>            : </a>
<span class="lineNum">      71 </span>            : template &lt;&gt;
<span class="lineNum">      72 </span><span class="lineNoCov">          0 : void caffe_add_scalar(const int N, const float alpha, float* Y) {</span>
<span class="lineNum">      73 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; N; ++i) {</span>
<span class="lineNum">      74 </span><span class="lineNoCov">          0 :     Y[i] += alpha;</span>
<span class="lineNum">      75 </span>            :   }
<span class="lineNum">      76 </span><span class="lineNoCov">          0 : }</span>
<a name="77"><span class="lineNum">      77 </span>            : </a>
<span class="lineNum">      78 </span>            : template &lt;&gt;
<span class="lineNum">      79 </span><span class="lineNoCov">          0 : void caffe_add_scalar(const int N, const double alpha, double* Y) {</span>
<span class="lineNum">      80 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; N; ++i) {</span>
<span class="lineNum">      81 </span><span class="lineNoCov">          0 :     Y[i] += alpha;</span>
<span class="lineNum">      82 </span>            :   }
<span class="lineNum">      83 </span><span class="lineNoCov">          0 : }</span>
<a name="84"><span class="lineNum">      84 </span>            : </a>
<span class="lineNum">      85 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">      86 </span><span class="lineCov">     952165 : void caffe_copy(const int N, const Dtype* X, Dtype* Y) {</span>
<span class="lineNum">      87 </span><span class="lineCov">     952165 :   if (X != Y) {</span>
<span class="lineNum">      88 </span><span class="lineCov">     952165 :     if (Caffe::mode() == Caffe::GPU) {</span>
<span class="lineNum">      89 </span>            : #ifndef CPU_ONLY
<span class="lineNum">      90 </span>            :       // NOLINT_NEXT_LINE(caffe/alt_fn)
<span class="lineNum">      91 </span>            :       CUDA_CHECK(cudaMemcpy(Y, X, sizeof(Dtype) * N, cudaMemcpyDefault));
<span class="lineNum">      92 </span>            : #else
<span class="lineNum">      93 </span><span class="lineNoCov">          0 :       NO_GPU;</span>
<span class="lineNum">      94 </span>            : #endif
<span class="lineNum">      95 </span>            :     } else {
<span class="lineNum">      96 </span><span class="lineCov">     952165 :       memcpy(Y, X, sizeof(Dtype) * N);  // NOLINT(caffe/alt_fn)</span>
<span class="lineNum">      97 </span>            :     }
<span class="lineNum">      98 </span>            :   }
<span class="lineNum">      99 </span><span class="lineCov">     952165 : }</span>
<span class="lineNum">     100 </span>            : 
<span class="lineNum">     101 </span>            : template void caffe_copy&lt;int&gt;(const int N, const int* X, int* Y);
<span class="lineNum">     102 </span>            : template void caffe_copy&lt;unsigned int&gt;(const int N, const unsigned int* X,
<span class="lineNum">     103 </span>            :     unsigned int* Y);
<span class="lineNum">     104 </span>            : template void caffe_copy&lt;float&gt;(const int N, const float* X, float* Y);
<span class="lineNum">     105 </span>            : template void caffe_copy&lt;double&gt;(const int N, const double* X, double* Y);
<a name="106"><span class="lineNum">     106 </span>            : </a>
<span class="lineNum">     107 </span>            : template &lt;&gt;
<span class="lineNum">     108 </span><span class="lineCov">      10000 : void caffe_scal&lt;float&gt;(const int N, const float alpha, float *X) {</span>
<span class="lineNum">     109 </span><span class="lineCov">      10000 :   cblas_sscal(N, alpha, X, 1);</span>
<span class="lineNum">     110 </span><span class="lineCov">      10000 : }</span>
<a name="111"><span class="lineNum">     111 </span>            : </a>
<span class="lineNum">     112 </span>            : template &lt;&gt;
<span class="lineNum">     113 </span><span class="lineNoCov">          0 : void caffe_scal&lt;double&gt;(const int N, const double alpha, double *X) {</span>
<span class="lineNum">     114 </span><span class="lineNoCov">          0 :   cblas_dscal(N, alpha, X, 1);</span>
<span class="lineNum">     115 </span><span class="lineNoCov">          0 : }</span>
<a name="116"><span class="lineNum">     116 </span>            : </a>
<span class="lineNum">     117 </span>            : template &lt;&gt;
<span class="lineNum">     118 </span><span class="lineCov">      80000 : void caffe_cpu_axpby&lt;float&gt;(const int N, const float alpha, const float* X,</span>
<span class="lineNum">     119 </span>            :                             const float beta, float* Y) {
<span class="lineNum">     120 </span>            :   cblas_saxpby(N, alpha, X, 1, beta, Y, 1);
<span class="lineNum">     121 </span><span class="lineCov">      80000 : }</span>
<a name="122"><span class="lineNum">     122 </span>            : </a>
<span class="lineNum">     123 </span>            : template &lt;&gt;
<span class="lineNum">     124 </span><span class="lineNoCov">          0 : void caffe_cpu_axpby&lt;double&gt;(const int N, const double alpha, const double* X,</span>
<span class="lineNum">     125 </span>            :                              const double beta, double* Y) {
<span class="lineNum">     126 </span>            :   cblas_daxpby(N, alpha, X, 1, beta, Y, 1);
<span class="lineNum">     127 </span><span class="lineNoCov">          0 : }</span>
<a name="128"><span class="lineNum">     128 </span>            : </a>
<span class="lineNum">     129 </span>            : template &lt;&gt;
<span class="lineNum">     130 </span><span class="lineNoCov">          0 : void caffe_add&lt;float&gt;(const int n, const float* a, const float* b,</span>
<span class="lineNum">     131 </span>            :     float* y) {
<span class="lineNum">     132 </span>            :   vsAdd(n, a, b, y);
<span class="lineNum">     133 </span><span class="lineNoCov">          0 : }</span>
<a name="134"><span class="lineNum">     134 </span>            : </a>
<span class="lineNum">     135 </span>            : template &lt;&gt;
<span class="lineNum">     136 </span><span class="lineNoCov">          0 : void caffe_add&lt;double&gt;(const int n, const double* a, const double* b,</span>
<span class="lineNum">     137 </span>            :     double* y) {
<span class="lineNum">     138 </span>            :   vdAdd(n, a, b, y);
<span class="lineNum">     139 </span><span class="lineNoCov">          0 : }</span>
<a name="140"><span class="lineNum">     140 </span>            : </a>
<span class="lineNum">     141 </span>            : template &lt;&gt;
<span class="lineNum">     142 </span><span class="lineNoCov">          0 : void caffe_sub&lt;float&gt;(const int n, const float* a, const float* b,</span>
<span class="lineNum">     143 </span>            :     float* y) {
<span class="lineNum">     144 </span>            :   vsSub(n, a, b, y);
<span class="lineNum">     145 </span><span class="lineNoCov">          0 : }</span>
<a name="146"><span class="lineNum">     146 </span>            : </a>
<span class="lineNum">     147 </span>            : template &lt;&gt;
<span class="lineNum">     148 </span><span class="lineNoCov">          0 : void caffe_sub&lt;double&gt;(const int n, const double* a, const double* b,</span>
<span class="lineNum">     149 </span>            :     double* y) {
<span class="lineNum">     150 </span>            :   vdSub(n, a, b, y);
<span class="lineNum">     151 </span><span class="lineNoCov">          0 : }</span>
<a name="152"><span class="lineNum">     152 </span>            : </a>
<span class="lineNum">     153 </span>            : template &lt;&gt;
<span class="lineNum">     154 </span><span class="lineNoCov">          0 : void caffe_mul&lt;float&gt;(const int n, const float* a, const float* b,</span>
<span class="lineNum">     155 </span>            :     float* y) {
<span class="lineNum">     156 </span>            :   vsMul(n, a, b, y);
<span class="lineNum">     157 </span><span class="lineNoCov">          0 : }</span>
<a name="158"><span class="lineNum">     158 </span>            : </a>
<span class="lineNum">     159 </span>            : template &lt;&gt;
<span class="lineNum">     160 </span><span class="lineNoCov">          0 : void caffe_mul&lt;double&gt;(const int n, const double* a, const double* b,</span>
<span class="lineNum">     161 </span>            :     double* y) {
<span class="lineNum">     162 </span>            :   vdMul(n, a, b, y);
<span class="lineNum">     163 </span><span class="lineNoCov">          0 : }</span>
<a name="164"><span class="lineNum">     164 </span>            : </a>
<span class="lineNum">     165 </span>            : template &lt;&gt;
<span class="lineNum">     166 </span><span class="lineCov">    8500640 : void caffe_div&lt;float&gt;(const int n, const float* a, const float* b,</span>
<span class="lineNum">     167 </span>            :     float* y) {
<span class="lineNum">     168 </span>            :   vsDiv(n, a, b, y);
<span class="lineNum">     169 </span><span class="lineCov">    8500640 : }</span>
<a name="170"><span class="lineNum">     170 </span>            : </a>
<span class="lineNum">     171 </span>            : template &lt;&gt;
<span class="lineNum">     172 </span><span class="lineNoCov">          0 : void caffe_div&lt;double&gt;(const int n, const double* a, const double* b,</span>
<span class="lineNum">     173 </span>            :     double* y) {
<span class="lineNum">     174 </span>            :   vdDiv(n, a, b, y);
<span class="lineNum">     175 </span><span class="lineNoCov">          0 : }</span>
<a name="176"><span class="lineNum">     176 </span>            : </a>
<span class="lineNum">     177 </span>            : template &lt;&gt;
<span class="lineNum">     178 </span><span class="lineNoCov">          0 : void caffe_powx&lt;float&gt;(const int n, const float* a, const float b,</span>
<span class="lineNum">     179 </span>            :     float* y) {
<span class="lineNum">     180 </span>            :   vsPowx(n, a, b, y);
<span class="lineNum">     181 </span><span class="lineNoCov">          0 : }</span>
<a name="182"><span class="lineNum">     182 </span>            : </a>
<span class="lineNum">     183 </span>            : template &lt;&gt;
<span class="lineNum">     184 </span><span class="lineNoCov">          0 : void caffe_powx&lt;double&gt;(const int n, const double* a, const double b,</span>
<span class="lineNum">     185 </span>            :     double* y) {
<span class="lineNum">     186 </span><span class="lineNoCov">          0 :   vdPowx(n, a, b, y);</span>
<span class="lineNum">     187 </span><span class="lineNoCov">          0 : }</span>
<a name="188"><span class="lineNum">     188 </span>            : </a>
<span class="lineNum">     189 </span>            : template &lt;&gt;
<span class="lineNum">     190 </span><span class="lineNoCov">          0 : void caffe_sqr&lt;float&gt;(const int n, const float* a, float* y) {</span>
<span class="lineNum">     191 </span>            :   vsSqr(n, a, y);
<span class="lineNum">     192 </span><span class="lineNoCov">          0 : }</span>
<a name="193"><span class="lineNum">     193 </span>            : </a>
<span class="lineNum">     194 </span>            : template &lt;&gt;
<span class="lineNum">     195 </span><span class="lineNoCov">          0 : void caffe_sqr&lt;double&gt;(const int n, const double* a, double* y) {</span>
<span class="lineNum">     196 </span>            :   vdSqr(n, a, y);
<span class="lineNum">     197 </span><span class="lineNoCov">          0 : }</span>
<a name="198"><span class="lineNum">     198 </span>            : </a>
<span class="lineNum">     199 </span>            : template &lt;&gt;
<span class="lineNum">     200 </span><span class="lineNoCov">          0 : void caffe_sqrt&lt;float&gt;(const int n, const float* a, float* y) {</span>
<span class="lineNum">     201 </span>            :   vsSqrt(n, a, y);
<span class="lineNum">     202 </span><span class="lineNoCov">          0 : }</span>
<a name="203"><span class="lineNum">     203 </span>            : </a>
<span class="lineNum">     204 </span>            : template &lt;&gt;
<span class="lineNum">     205 </span><span class="lineNoCov">          0 : void caffe_sqrt&lt;double&gt;(const int n, const double* a, double* y) {</span>
<span class="lineNum">     206 </span>            :   vdSqrt(n, a, y);
<span class="lineNum">     207 </span><span class="lineNoCov">          0 : }</span>
<a name="208"><span class="lineNum">     208 </span>            : </a>
<span class="lineNum">     209 </span>            : template &lt;&gt;
<span class="lineNum">     210 </span><span class="lineCov">     850064 : void caffe_exp&lt;float&gt;(const int n, const float* a, float* y) {</span>
<span class="lineNum">     211 </span>            :   vsExp(n, a, y);
<span class="lineNum">     212 </span><span class="lineCov">     850064 : }</span>
<a name="213"><span class="lineNum">     213 </span>            : </a>
<span class="lineNum">     214 </span>            : template &lt;&gt;
<span class="lineNum">     215 </span><span class="lineNoCov">          0 : void caffe_exp&lt;double&gt;(const int n, const double* a, double* y) {</span>
<span class="lineNum">     216 </span>            :   vdExp(n, a, y);
<span class="lineNum">     217 </span><span class="lineNoCov">          0 : }</span>
<a name="218"><span class="lineNum">     218 </span>            : </a>
<span class="lineNum">     219 </span>            : template &lt;&gt;
<span class="lineNum">     220 </span><span class="lineNoCov">          0 : void caffe_log&lt;float&gt;(const int n, const float* a, float* y) {</span>
<span class="lineNum">     221 </span>            :   vsLn(n, a, y);
<span class="lineNum">     222 </span><span class="lineNoCov">          0 : }</span>
<a name="223"><span class="lineNum">     223 </span>            : </a>
<span class="lineNum">     224 </span>            : template &lt;&gt;
<span class="lineNum">     225 </span><span class="lineNoCov">          0 : void caffe_log&lt;double&gt;(const int n, const double* a, double* y) {</span>
<span class="lineNum">     226 </span>            :   vdLn(n, a, y);
<span class="lineNum">     227 </span><span class="lineNoCov">          0 : }</span>
<a name="228"><span class="lineNum">     228 </span>            : </a>
<span class="lineNum">     229 </span>            : template &lt;&gt;
<span class="lineNum">     230 </span><span class="lineNoCov">          0 : void caffe_abs&lt;float&gt;(const int n, const float* a, float* y) {</span>
<span class="lineNum">     231 </span>            :     vsAbs(n, a, y);
<span class="lineNum">     232 </span><span class="lineNoCov">          0 : }</span>
<a name="233"><span class="lineNum">     233 </span>            : </a>
<span class="lineNum">     234 </span>            : template &lt;&gt;
<span class="lineNum">     235 </span><span class="lineNoCov">          0 : void caffe_abs&lt;double&gt;(const int n, const double* a, double* y) {</span>
<span class="lineNum">     236 </span>            :     vdAbs(n, a, y);
<a name="237"><span class="lineNum">     237 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     238 </span>            : 
<span class="lineNum">     239 </span><span class="lineCov">          2 : unsigned int caffe_rng_rand() {</span>
<span class="lineNum">     240 </span><span class="lineCov">          2 :   return (*caffe_rng())();</span>
<span class="lineNum">     241 </span>            : }
<a name="242"><span class="lineNum">     242 </span>            : </a>
<span class="lineNum">     243 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     244 </span><span class="lineCov">          8 : Dtype caffe_nextafter(const Dtype b) {</span>
<span class="lineNum">     245 </span>            :   return boost::math::nextafter&lt;Dtype&gt;(
<span class="lineNum">     246 </span><span class="lineCov">          8 :       b, std::numeric_limits&lt;Dtype&gt;::max());</span>
<span class="lineNum">     247 </span>            : }
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span>            : template
<span class="lineNum">     250 </span>            : float caffe_nextafter(const float b);
<span class="lineNum">     251 </span>            : 
<span class="lineNum">     252 </span>            : template
<span class="lineNum">     253 </span>            : double caffe_nextafter(const double b);
<a name="254"><span class="lineNum">     254 </span>            : </a>
<span class="lineNum">     255 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     256 </span><span class="lineCov">          8 : void caffe_rng_uniform(const int n, const Dtype a, const Dtype b, Dtype* r) {</span>
<span class="lineNum">     257 </span><span class="lineCov">          8 :   CHECK_GE(n, 0);</span>
<span class="lineNum">     258 </span><span class="lineCov">         16 :   CHECK(r);</span>
<span class="lineNum">     259 </span><span class="lineCov">          8 :   CHECK_LE(a, b);</span>
<span class="lineNum">     260 </span><span class="lineCov">          8 :   boost::uniform_real&lt;Dtype&gt; random_distribution(a, caffe_nextafter&lt;Dtype&gt;(b));</span>
<span class="lineNum">     261 </span>            :   boost::variate_generator&lt;caffe::rng_t*, boost::uniform_real&lt;Dtype&gt; &gt;
<span class="lineNum">     262 </span>            :       variate_generator(caffe_rng(), random_distribution);
<span class="lineNum">     263 </span><span class="lineCov">    1722008 :   for (int i = 0; i &lt; n; ++i) {</span>
<span class="lineNum">     264 </span><span class="lineCov">    1722000 :     r[i] = variate_generator();</span>
<span class="lineNum">     265 </span>            :   }
<span class="lineNum">     266 </span><span class="lineCov">          8 : }</span>
<span class="lineNum">     267 </span>            : 
<span class="lineNum">     268 </span>            : template
<span class="lineNum">     269 </span>            : void caffe_rng_uniform&lt;float&gt;(const int n, const float a, const float b,
<span class="lineNum">     270 </span>            :                               float* r);
<span class="lineNum">     271 </span>            : 
<span class="lineNum">     272 </span>            : template
<span class="lineNum">     273 </span>            : void caffe_rng_uniform&lt;double&gt;(const int n, const double a, const double b,
<span class="lineNum">     274 </span>            :                                double* r);
<a name="275"><span class="lineNum">     275 </span>            : </a>
<span class="lineNum">     276 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     277 </span><span class="lineNoCov">          0 : void caffe_rng_gaussian(const int n, const Dtype a,</span>
<span class="lineNum">     278 </span>            :                         const Dtype sigma, Dtype* r) {
<span class="lineNum">     279 </span><span class="lineNoCov">          0 :   CHECK_GE(n, 0);</span>
<span class="lineNum">     280 </span><span class="lineNoCov">          0 :   CHECK(r);</span>
<span class="lineNum">     281 </span><span class="lineNoCov">          0 :   CHECK_GT(sigma, 0);</span>
<span class="lineNum">     282 </span>            :   boost::normal_distribution&lt;Dtype&gt; random_distribution(a, sigma);
<span class="lineNum">     283 </span>            :   boost::variate_generator&lt;caffe::rng_t*, boost::normal_distribution&lt;Dtype&gt; &gt;
<span class="lineNum">     284 </span>            :       variate_generator(caffe_rng(), random_distribution);
<span class="lineNum">     285 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; n; ++i) {</span>
<span class="lineNum">     286 </span><span class="lineNoCov">          0 :     r[i] = variate_generator();</span>
<span class="lineNum">     287 </span>            :   }
<span class="lineNum">     288 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     289 </span>            : 
<span class="lineNum">     290 </span>            : template
<span class="lineNum">     291 </span>            : void caffe_rng_gaussian&lt;float&gt;(const int n, const float mu,
<span class="lineNum">     292 </span>            :                                const float sigma, float* r);
<span class="lineNum">     293 </span>            : 
<span class="lineNum">     294 </span>            : template
<span class="lineNum">     295 </span>            : void caffe_rng_gaussian&lt;double&gt;(const int n, const double mu,
<span class="lineNum">     296 </span>            :                                 const double sigma, double* r);
<a name="297"><span class="lineNum">     297 </span>            : </a>
<span class="lineNum">     298 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     299 </span><span class="lineNoCov">          0 : void caffe_rng_bernoulli(const int n, const Dtype p, int* r) {</span>
<span class="lineNum">     300 </span><span class="lineNoCov">          0 :   CHECK_GE(n, 0);</span>
<span class="lineNum">     301 </span><span class="lineNoCov">          0 :   CHECK(r);</span>
<span class="lineNum">     302 </span><span class="lineNoCov">          0 :   CHECK_GE(p, 0);</span>
<span class="lineNum">     303 </span><span class="lineNoCov">          0 :   CHECK_LE(p, 1);</span>
<span class="lineNum">     304 </span>            :   boost::bernoulli_distribution&lt;Dtype&gt; random_distribution(p);
<span class="lineNum">     305 </span>            :   boost::variate_generator&lt;caffe::rng_t*, boost::bernoulli_distribution&lt;Dtype&gt; &gt;
<span class="lineNum">     306 </span>            :       variate_generator(caffe_rng(), random_distribution);
<span class="lineNum">     307 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; n; ++i) {</span>
<span class="lineNum">     308 </span><span class="lineNoCov">          0 :     r[i] = variate_generator();</span>
<span class="lineNum">     309 </span>            :   }
<span class="lineNum">     310 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     311 </span>            : 
<span class="lineNum">     312 </span>            : template
<span class="lineNum">     313 </span>            : void caffe_rng_bernoulli&lt;double&gt;(const int n, const double p, int* r);
<span class="lineNum">     314 </span>            : 
<span class="lineNum">     315 </span>            : template
<span class="lineNum">     316 </span>            : void caffe_rng_bernoulli&lt;float&gt;(const int n, const float p, int* r);
<a name="317"><span class="lineNum">     317 </span>            : </a>
<span class="lineNum">     318 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     319 </span><span class="lineNoCov">          0 : void caffe_rng_bernoulli(const int n, const Dtype p, unsigned int* r) {</span>
<span class="lineNum">     320 </span><span class="lineNoCov">          0 :   CHECK_GE(n, 0);</span>
<span class="lineNum">     321 </span><span class="lineNoCov">          0 :   CHECK(r);</span>
<span class="lineNum">     322 </span><span class="lineNoCov">          0 :   CHECK_GE(p, 0);</span>
<span class="lineNum">     323 </span><span class="lineNoCov">          0 :   CHECK_LE(p, 1);</span>
<span class="lineNum">     324 </span>            :   boost::bernoulli_distribution&lt;Dtype&gt; random_distribution(p);
<span class="lineNum">     325 </span>            :   boost::variate_generator&lt;caffe::rng_t*, boost::bernoulli_distribution&lt;Dtype&gt; &gt;
<span class="lineNum">     326 </span>            :       variate_generator(caffe_rng(), random_distribution);
<span class="lineNum">     327 </span><span class="lineNoCov">          0 :   for (int i = 0; i &lt; n; ++i) {</span>
<span class="lineNum">     328 </span><span class="lineNoCov">          0 :     r[i] = static_cast&lt;unsigned int&gt;(variate_generator());</span>
<span class="lineNum">     329 </span>            :   }
<span class="lineNum">     330 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     331 </span>            : 
<span class="lineNum">     332 </span>            : template
<span class="lineNum">     333 </span>            : void caffe_rng_bernoulli&lt;double&gt;(const int n, const double p, unsigned int* r);
<span class="lineNum">     334 </span>            : 
<span class="lineNum">     335 </span>            : template
<span class="lineNum">     336 </span>            : void caffe_rng_bernoulli&lt;float&gt;(const int n, const float p, unsigned int* r);
<a name="337"><span class="lineNum">     337 </span>            : </a>
<span class="lineNum">     338 </span>            : template &lt;&gt;
<span class="lineNum">     339 </span><span class="lineCov">      24202 : float caffe_cpu_strided_dot&lt;float&gt;(const int n, const float* x, const int incx,</span>
<span class="lineNum">     340 </span>            :     const float* y, const int incy) {
<span class="lineNum">     341 </span><span class="lineCov">      24202 :   return cblas_sdot(n, x, incx, y, incy);</span>
<span class="lineNum">     342 </span>            : }
<a name="343"><span class="lineNum">     343 </span>            : </a>
<span class="lineNum">     344 </span>            : template &lt;&gt;
<span class="lineNum">     345 </span><span class="lineNoCov">          0 : double caffe_cpu_strided_dot&lt;double&gt;(const int n, const double* x,</span>
<span class="lineNum">     346 </span>            :     const int incx, const double* y, const int incy) {
<span class="lineNum">     347 </span><span class="lineNoCov">          0 :   return cblas_ddot(n, x, incx, y, incy);</span>
<span class="lineNum">     348 </span>            : }
<a name="349"><span class="lineNum">     349 </span>            : </a>
<span class="lineNum">     350 </span>            : template &lt;typename Dtype&gt;
<span class="lineNum">     351 </span><span class="lineCov">      24202 : Dtype caffe_cpu_dot(const int n, const Dtype* x, const Dtype* y) {</span>
<span class="lineNum">     352 </span><span class="lineCov">      24202 :   return caffe_cpu_strided_dot(n, x, 1, y, 1);</span>
<span class="lineNum">     353 </span>            : }
<span class="lineNum">     354 </span>            : 
<span class="lineNum">     355 </span>            : template
<span class="lineNum">     356 </span>            : float caffe_cpu_dot&lt;float&gt;(const int n, const float* x, const float* y);
<span class="lineNum">     357 </span>            : 
<span class="lineNum">     358 </span>            : template
<span class="lineNum">     359 </span>            : double caffe_cpu_dot&lt;double&gt;(const int n, const double* x, const double* y);
<a name="360"><span class="lineNum">     360 </span>            : </a>
<span class="lineNum">     361 </span>            : template &lt;&gt;
<span class="lineNum">     362 </span><span class="lineNoCov">          0 : float caffe_cpu_asum&lt;float&gt;(const int n, const float* x) {</span>
<span class="lineNum">     363 </span><span class="lineNoCov">          0 :   return cblas_sasum(n, x, 1);</span>
<span class="lineNum">     364 </span>            : }
<a name="365"><span class="lineNum">     365 </span>            : </a>
<span class="lineNum">     366 </span>            : template &lt;&gt;
<span class="lineNum">     367 </span><span class="lineNoCov">          0 : double caffe_cpu_asum&lt;double&gt;(const int n, const double* x) {</span>
<span class="lineNum">     368 </span><span class="lineNoCov">          0 :   return cblas_dasum(n, x, 1);</span>
<span class="lineNum">     369 </span>            : }
<a name="370"><span class="lineNum">     370 </span>            : </a>
<span class="lineNum">     371 </span>            : template &lt;&gt;
<span class="lineNum">     372 </span><span class="lineNoCov">          0 : void caffe_cpu_scale&lt;float&gt;(const int n, const float alpha, const float *x,</span>
<span class="lineNum">     373 </span>            :                             float* y) {
<span class="lineNum">     374 </span><span class="lineNoCov">          0 :   cblas_scopy(n, x, 1, y, 1);</span>
<span class="lineNum">     375 </span><span class="lineNoCov">          0 :   cblas_sscal(n, alpha, y, 1);</span>
<span class="lineNum">     376 </span><span class="lineNoCov">          0 : }</span>
<a name="377"><span class="lineNum">     377 </span>            : </a>
<span class="lineNum">     378 </span>            : template &lt;&gt;
<span class="lineNum">     379 </span><span class="lineNoCov">          0 : void caffe_cpu_scale&lt;double&gt;(const int n, const double alpha, const double *x,</span>
<span class="lineNum">     380 </span>            :                              double* y) {
<span class="lineNum">     381 </span><span class="lineNoCov">          0 :   cblas_dcopy(n, x, 1, y, 1);</span>
<span class="lineNum">     382 </span><span class="lineNoCov">          0 :   cblas_dscal(n, alpha, y, 1);</span>
<a name="383"><span class="lineNum">     383 </span><span class="lineNoCov">          0 : }</span></a>
<span class="lineNum">     384 </span>            : 
<span class="lineNum">     385 </span><span class="lineCov">          3 : }  // namespace caffe</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.12</a></td></tr>
  </table>
  <br>

</body>
</html>
